package com.whf.android.jar.constants.business;

import com.whf.android.jar.constants.BaseEnum;

import java.util.Objects;


/**
 * 性别的枚举类型
 *
 * @author qf
 * @version 1.0.1
 */
public enum SexEnum implements BaseEnum<Integer> {

    UN_KNOW(0, "未知"),
    MAN(1, "男"),
    WOMAN(2, "女");


    private final int value;
    private final String desc;

    SexEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    @Override
    public boolean isExists(Integer value) {
        for (SexEnum e : SexEnum.values()) {
            if (Objects.equals(e.getValue(), value)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String value2Desc(Integer value) {
        if (Objects.equals(UN_KNOW.getValue(), value)) {
            return UN_KNOW.getDesc();
        }
        if (Objects.equals(MAN.getValue(), value)) {
            return MAN.getDesc();
        }
        return WOMAN.getDesc();
    }
}
